package com.hdy.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;



@Configuration
@EnableSwagger2     //开启swagger2
public class SwaggerConfig {

    //http://localhost:8080/swagger-ui.html
    //创建一个docket对象，设置属性，配置信息放在docket对象中
    @Bean //方法返回的对象docket,放在spring框架中，swagger框架会自动从spring框架中取docket对象
    //docket:接口文档
    public Docket createDocket(){
        ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder();
        ApiInfo apiInfo = apiInfoBuilder.title("大大怪将军的API文档").build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2);

        docket.apiInfo(apiInfo);

        //设置为那些controller生成接口文档
        docket.select().apis(RequestHandlerSelectors.any());

        return  docket;

    }

}
